<?php

	require_once ($_SERVER['DOCUMENT_ROOT']."/Auditing/data/config.php");
	require_once ($_SERVER['DOCUMENT_ROOT']."/Auditing/data/DBConn.php");
	
		
	function checkLogin($userName,$pass){
		$check = 0;
		$user = addslashes($userName);
		$pass = md5($pass); 
		
	
			$result=mysql_query("select * from ota_users where user_name='$user' and password='$pass'");

			//check that at least one row was returned
			
			$rowCheck = mysql_num_rows($result);
			if($rowCheck > 0){
			while($row = mysql_fetch_array($result)){
			
			  //start the session and register a variable

			  session_start();
			  $_SESSION['username'] = $userName;
			  $_SESSION['userId']=$row['user_id'];

			  $check=1;			  		
			}				
		}		
		return $check;
	}
	
	function logOut(){		
		session_start();
		return session_destroy();
	}
?>